<?php
require_once('../db/check_login.php');
require_once('../db/config.php');
$db=new db($config);
$getCommenter=$_GET['getCommenter'];
$getArticleId=$_GET['getArticleId'];
$getContent=$_GET['getContent'];
$data=array(
'articleId'=>$getArticleId,
'commenter'=>$getCommenter,
'comment_time'=>date('Y-m-d H:i:s'),
'content'=>$getContent
);
$insertId=$db->insert('artcomment',$data);
if($insertId>0){
$insertData=$db->foundbyId('artcomment',$insertId);
$userData=$db->foundOnebyWhere('user',"user='$getCommenter'");//找到评论者的头像
$commentData="<div class='commentBox'><div class='boxUserImg'><img src='".$userData['userImg']."' width='45px' height='45px'/></div><div class='boxUser'><span class='userName'>".$getCommenter."</span></div><div class='boxContent'>".$getContent."</div><div class='boxBottom' attr-id='".$insertId."_0'>".$insertData['comment_time']."<span class='reply' attr-show='off' attr-id='".$insertId."_0' attr-user='".$getCommenter."'><a href='javascript:;'>回复</a></span><span class='praiseNum' praise-id='".$insertId."_0'>(0)</span><span class='praise' attr-praiseId='".$insertId."_0'><a href='javascript:;'>赞</a></span>
</div>";
	echo json_encode(array("errorCode"=>"0","commentData"=>$commentData,"msg"=>"评论成功"));
}else{
	echo json_encode(array("errorCode"=>"1","msg"=>"评论失败"));	
}

?>